/*
 * @Author: szx
 * @Date: 2022-05-02 12:33:08
 * @LastEditTime: 2022-05-02 12:37:30
 * @Description:
 * @FilePath: \leetcode\900-999\908\908.js
 */
/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var smallestRangeI = function (nums, k) {
    const min = Math.min(...nums);
    const max = Math.max(...nums);
    if (max - min > 2 * k) return max - min - 2 * k;
    if (max - min < 2 * k) return max - min;
};
